package com.ylw.entity;

import org.apache.log4j.Logger;

import java.util.ArrayList;
import java.util.List;

/**
 * 请求入参和返回参数的基本元素
 */
public class Parameter {
    public static final Logger logger = Logger.getLogger(Define.class);



    public Parameter() {
    }

    public Parameter(String name, String type, String remark) {
        this.name = name;
        this.type = type;
        this.remark = remark;
    }

    private String name;//参数名称
    private String type;//参数类型
    private String remark;//备注

    private Parameter parent;//父节点

    private List<Parameter> children;//字节点


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Parameter getParent() {
        return parent;
    }

    public void setParent(Parameter parent) {
        this.parent = parent;
    }

    public List<Parameter> getChildren() {
        return children;
    }

    public void setChildren(List<Parameter> children) {
        this.children = children;
    }

    public void addChild(Parameter child){
        if(children == null){
            children  = new ArrayList();
        }
        children.add(child);
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("{");
        sb.append("\"name\":\"").append(name).append('\"');
        sb.append(",\"type\":\"").append(type).append('\"');
        sb.append(",\"remark\":\"").append(remark).append('\"');
        sb.append('}');
        return sb.toString();
    }
}
